package com.ys.utils;

import com.ys.enumeration.BeanScope;

/**
 * @projectName: Spring-Mini
 * @className:
 * @description: 字符串工具类
 * @author: yangshuang
 * @date: 2016/12/9 22:26
 */
public class StringUtils {

    public static boolean isEmpty(String str) {
        if (str == null) {
            return true;
        }
        if (str.trim().equals("")) {
            return true;
        }
        return false;
    }

    public static boolean equals(String str1, String str2) {
        if (str1 == str2) {//引用地址相同
            return true;
        }
        if (str1 == null || str2 == null) {
            return false;
        }
        str1 = str1.trim();
        str2 = str2.trim();
        if (str1.equals(str2)) {
            return true;
        }
        return false;
    }

    /**
     * 判断对象是否为空
     *
     * @param object
     * @return
     */
    public static boolean isNull(Object object) {
        return object == null;
    }

    /**
     * 将字符串类型的beanScope转换为枚举类型的
     *
     * @param beanScopeStr
     * @return
     */
    public static BeanScope convertStr2Enum(String beanScopeStr) {
        if (beanScopeStr == null || beanScopeStr == "") {//默认单例
            return BeanScope.SINGLETION;
        } else {
            return Enum.valueOf(BeanScope.class, beanScopeStr.trim());
        }

    }
}
